# 修改元组元素
t1 = (1, 2, 3,)
t2 = ('a', 'b', 'c')
t3 = t1 + t2
print(t3)

t3 = (1, 2, 3, 4, 5, 6)
print(t3)
del t3

# 任务
n = input('姓名：')
t = input('电话：')
e = input('邮箱：')
a = input('地址：')
t1 = ("姓名：", n, "电话:", t, "邮箱:", e, "地址：", a)
print(t1)

# 1.1空列表
l1 = []
print(l1)
# 1.2有元素列表
l2 = [1, 2, "python", "java"]
print(l2)
print(type(l2))
# 2.1空列表
l3 = list()
print(l3)
# 2.2字符串转列表
l4 = list("hello world")
print(l4)
# 2.3元组转列表
t5 = tuple("hello")
print(t5)
l5 = list(t5)
print(l5)
# 2.4将range函数转化成列表
l6 = list(range(5))
print(l6)

l7 = [1, 2, 3, 4, 'p', 'w', 'r']
print(l7[4])
print(l7[-2])

l8 = ['p', 'y', 't', 'h', 'o', 'n']
print(l8[2:5])
# 前三个元素
print(l8[:3])
# 后三个元素
print(l8[3:])
# 正数
print(l8[1::2])
# 负数
print(l8[-3:-1])
# 步长是负数
print(l8[::-1])

l9 = [1, 2, 3, 4, "python", "java", 'c']
for i in l9:
    print(i)

l10 = [10, 56, 34, 2, 56, 44, 7]
l10[2] = 100
print(l10)
l11 = [10, 56, 34, 2, 56, 44, 7]
l11[1:4] = [45, -56, 98]
print(l11)

# append()用于在列表的末尾追加元素
l12 = ['a', 'b', 'c', 'f']
print(l12)
l12.append(['e', 'f'])
print(l12)

# extend()在列表的末尾一次添加多个元素
l13 = ['a', 'b', 'c']
l13.extend('d')
print(l13)
# 列表添加列表
l13.extend(['e', 'f', 'g', 'h'])
print(l13)
l13.extend('world')
print(l13)

l14 = ['python', 'c', 'java']
l14.insert(2, 'go')
print(l14)
